#!/usr/bin/env python3
import time
from multiprocessing import Manager, Queue

from nicegui import run, ui
i=0
def turn_loading(cnt:int,is_done=False):  # 等待
    with ui.row():
        if not is_done:
            ui.spinner(color="negative")
        else:
            ui.icon("done",color='positive')
        ui.label(f'进行第{i+1}个测试点')

def run_turn():  # 执行函数
    time.sleep(3)

async def on_run_turn():  # 异步,防止卡顿
    global i
    loading_box.clear()
    with loading_box:
        for i in range(3):
            loading = ui.refreshable(turn_loading)
            loading(i)
            await run.cpu_bound(run_turn)  # 调用执行函数
            loading.refresh(is_done=True)
    loading_box.clear()
    ui.notify('提交完毕!!!')

ui.button('提交代码',on_click=on_run_turn)

loading_box = ui.column()

ui.run()